import { BroadCastCall } from "../../broadCast/BroadCastCall";
import { MessageBlock } from "../../../../../Framework/MQ/MessageBlock";
import { SBossFieldMyScore } from "../../../../../Message/Public/SBossFieldMyScore";
import { Cache } from "../../../cache/Cache";
import { AttributeValue } from "../../../scene/player/AttributeValue";
import { AttributeTextType } from "../../../scene/player/type/AttributeTextType";
import { NetDispatcher } from "../../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../../mvc/ServerCommand";
//class BossFieldPlayerCreditCommand
    
    export  class BossFieldPlayerCreditCommand extends BroadCastCall
    {
        constructor(arg1: Object)
        {
            super(arg1);
            return;
        }

        public /* override */ call(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SBossFieldMyScore;
            var loc2=true;
            var loc3=0;
            if (Cache.instance.bossField.bossFieldMyScore) 
            {
                loc2 = loc1.honour > Cache.instance.bossField.bossFieldMyScore.honour;
                loc3 = Math.abs(loc1.honour - Cache.instance.bossField.bossFieldMyScore.honour);
            }
            else 
            {
                loc3 = loc1.honour;
            }
            var loc4=new AttributeValue(AttributeTextType.honor, loc2, loc3);
            if (loc3 != 0) 
            {
                NetDispatcher.dispatchCmd(ServerCommand.RoleSingleAttributeChange, loc4);
            }
            Cache.instance.bossField.bossFieldMyScore = loc1;
            NetDispatcher.dispatchCmd(ServerCommand.BossFieldPlayerCreditUpdate, loc1);
            return;
        }
    }
